package cn.itcast.demo.web;

import cn.itcast.demo.pojo.User;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;

import java.util.Arrays;

/**
 * @author 虎哥
 */
@Controller
public class HelloController {

    @GetMapping("hello")
    public String toHello(Model model) {
        User user1 = new User("张虎翼", 18);
        User user2 = new User("胡歌", 28);
        User user3 = new User("蔡蔡", 38);
        model.addAttribute("msg", "hello, thymeleaf");

        model.addAttribute("user", user1);

        model.addAttribute("list", Arrays.asList(user1, user2, user3));
        return "hello";
    }
}
